//引入VueRouter
import VueRouter from 'vue-router'
//引入路由 组件
import Home from '../components/Home'
import Readme from '@/components/Readme.vue'
import Analyze from "@/components/Analyze.vue";
import Setting from "@/components/Setting.vue";
import Database from "@/components/Database.vue";
import Game from "@/components/collect/Collect.vue";
import Opening from "@/components/Opening.vue";
import Version from "@/components/Version.vue";
import User from "@/components/user/User.vue";
import MidGame from "@/components/midGame/MidGame.vue";
import Exercise from "@/components/user/Exercise.vue";
import Chart from "@/components/user/Chart.vue";
import EditHandle from "@/components/boardEdit/EditHandle.vue";

//创建router实例对象，去管理一组一组的路由规则
const router = new VueRouter({
  routes: [
    // 配置默认页面
    {
      path: '/',
      redirect: '/home/analyze',
      meta: {
        keepAlive: true,
      }
    },
    {
      path: '/home',
      name: 'Home',
      component: Home,
      children: [ //通过children配置子级路由
        {
          path: 'analyze',    // 分析
          name: 'Analyze',
          component: Analyze,
          meta: {
            title: '分析',    // 提供给后置路由守卫修改页面标题
            keepAlive: true,
          }
        },
        {
          path: 'opening',     // 开局
          name: 'Opening',
          component: Opening,
          meta: {
            title: '开局',
            keepAlive: true,
          }
        },
        {
          path: 'game',     // 棋局
          name: 'Game',
          component: Game,
          meta: {
            title: '棋局',
            keepAlive: true,
          }
        },
        {
          path: 'midGame',     // 中残局
          name: 'MidGame',
          component: MidGame,
          meta: {
            title: '中残局',
            keepAlive: true,
          }
        },
        {
          path: 'user',     // 用户数据
          name: 'User',
          component: User,
          meta: {
            title: '用户数据',
            keepAlive: true,
          }
        },
        {
          path: 'exercise',     // 习题
          name: 'Exercise',
          component: Exercise,
          meta: {
            title: '习题',
            keepAlive: true,
          }
        },
        {
          path: 'chart',     // 数据统计
          name: 'Chart',
          component: Chart,
          meta: {
            title: '数据统计',
          }
        },
        {
          path: 'database',     // 局面库
          name: 'Database',
          component: Database,
          meta: {
            title: '局面库',
            keepAlive: true,
          }
        },
        {
          path: 'edit',     // 棋盘编辑器
          name: 'EditHandle',
          component: EditHandle,
          meta: {
            title: '棋盘编辑',
            keepAlive: true,
          }
        },
        {
          path: 'setting',     // 设置
          name: 'Setting',
          component: Setting,
          meta: {
            title: '设置'
          }
        },
        {
          path: 'readme',     // 使用手册
          name: 'Readme',
          component: Readme,
          meta: {
            title: '使用手册'
          }
        },
        {
          path: 'version',     // 更新日志
          name: 'Version',
          component: Version,
          meta: {
            title: '更新日志'
          }
        },
      ]
    }
  ]
})
//暴露router
export default router